home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / jjbqc.zip / JJBSHOW5.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  7KB  |  178 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. /**************************************************************************
  7.  *                                                                        *
  8.  *                           JJBSHOW5.C                                   *
  9.  *                                                                        *
  10.  *   Copyright (c) 1989, JJB. All rights reserved.                        *
  11.  *                                                                        *
  12.  *                                                                        *
  13.  *   This example shows you how to use the 'enter' functions so you can   *
  14.  *   input entire screens of data.                                        *
  15.  *                                                                        *
  16.  *     JJB, 9236 church Rd suite 1082, Dallas, Tx 75231 (214) 341-1635    *
  17.  **************************************************************************/
  18.  
  19.  
  20. /***************************************************************************
  21.  *                                                                         *
  22.  * To make an .exe file JJBSHOW5.EXE for this program, from DOS enter:     *
  23.  *                                                                         *
  24.  *     QCL  /c  /AM  JJBSHOW5.C                                            *
  25.  *     LINK  JJBSHOW5.OBJ + JJB + JJBINPUT+JJBDOLLR ,,, C:LIB\,            *
  26.  *                                                                         *
  27.  ***************************************************************************/
  28.  
  29.  
  30. #include "c:\bin\jjbkbd.h"
  31. #include "c:\bin\jjbset.h"
  32.  
  33.  
  34. main() {
  35.  
  36.     jjb_initalize();        /* initalize the jjb functions             */
  37.  
  38.     jjb_setup();            /* set up your options and assign functions*/
  39.  
  40.     jjb_start();            /* start executing the default option      */
  41.  
  42.     }
  43.  
  44.  
  45. /****************************************************************************
  46.  *                                                                          *
  47.  *                      SAMPLE ENTER FUNCTION                               *
  48.  *                                                                          *
  49.  ****************************************************************************/
  50.  
  51.  
  52. update_cust()  {  int x;  unsigned long lfrom, lto;
  53.     char buffer[256];    /*  customer I/O buffer    */
  54.  
  55.     /*   define the define pointers   */
  56.     char *name, *street, *city, *phone1, *phone2, *phone3,
  57.          *comment, *mo, *day, *year, *check , *amt,
  58.          *pak = "  ";  /* for press any key   */
  59.  
  60.     /*   define the data lengths.        */
  61.     /*   if you change any data length, the buffer pointers below
  62.          will automatically be adjusted for the new address        */
  63.  
  64.     int lname    = 44,
  65.         lstreet  = 30,
  66.         lcity    = 30,
  67.         lphone1  =  3,
  68.         lphone2  =  3,
  69.         lphone3  =  4,
  70.         lcomment =  30,
  71.         lmo      = 2,
  72.         lday     = 2,
  73.         lyear    = 2,
  74.         lcheck   = 6,
  75.         lamt     = 14;
  76.         x=1;
  77.  
  78.     /* store buffer address in the character pointers     */
  79.         name    = &buffer[x];   x += lname    +1;
  80.         street  = &buffer[x];   x += lstreet  +1;
  81.         city    = &buffer[x];   x += lcity    +1;
  82.         phone1  = &buffer[x];   x += lphone1  +1;
  83.         phone2  = &buffer[x];   x += lphone2  +1;
  84.         phone3  = &buffer[x];   x += lphone3  +1;
  85.         comment = &buffer[x];   x += lcomment +1;
  86.         mo      = &buffer[x];   x += lmo      +1;
  87.         day     = &buffer[x];   x += lday     +1;
  88.         year    = &buffer[x];   x += lyear    +1;
  89.         check   = &buffer[x];   x += lcheck   +1;
  90.         amt     = &buffer[x];   x += lamt     +1;
  91.  
  92.     /*a  zero data buffer  */
  93.     for (x=0; x<256; ++x) buffer[x] = '\0';
  94.  
  95. /* Normally you would read the data file, but since we don't have a data
  96.    file in this example, we need to fill the data buffer as follows:  */
  97.  
  98.     name    = "John Thomas Wellington";
  99.     street  = "1527 South Meadow Road";
  100.     city    = "Dallas, TX    75247";
  101.     phone1  = "214";  phone2 = "357";  phone3 = "8934";
  102.     comment = "Place any comment here";
  103.     mo      = "11";         /* JJB S&W (strings & windows) will be    */
  104.     day     = "24";         /* released in 1989 and it will have      */
  105.     year    = "88";         /* complete date handling source for you. */
  106.     check   = "34512";
  107.  
  108.     amt     = "";
  109.     vloc(15,22); vfs("(   )    -");    /*  for phone number  */
  110.     vloc(19,22); vfs("  -  -  ");      /*  for date  */
  111.  
  112.  
  113.     vloc(4,3); vfs("Note: ");
  114.     /* Notice '1,9' on next line. It means down 1, over 9             */
  115.     vfscr("At any time while entering, you can press: ALT to exit",1,9);
  116.     vfscr("UP or DOWN ARROWS to move cursor, '*' to remove data.");
  117.     vfscr("Plus any assigned function keys F1 thru F8, or F9 to DOS. ");
  118.     vfscr("SPACE BAR is same as RETURN if first character entered.");
  119.  
  120. /*  BEGIN....AGAIN  is a continuous while loop                          */
  121. /*  eptr(4) will be true only if the entry pointer equals 4             */
  122. /*  Each enter( increments the entry pointer by 1                       */
  123. /*  In addition to entering, JJB also displays the data from the buffer */
  124. /*  Since the buffer is updated directly, the only thing left for the   */
  125. /*    programmer to do is to read & write the record to the disk file.  */
  126. /*  The first time thru the enter( will just display the screen.        */
  127. /*  until it starts with (x)                                            */
  128.  
  129.     eptr_reset();    /* set eptr (enter pointer) to 1        */
  130.  
  131.  
  132.     lfrom = 100;            /* see enter_lnum(  below       */
  133.     lto = 999998;
  134.  
  135. BEGIN
  136.  
  137.   if (eptr(1))  enter(9,9 ,   "Enter name: ",name,   lname);
  138.   if (eptr(2))  enter(11,12,     " street: ",street, lstreet);
  139.   if (eptr(3))  enter(13,12,     "   city: ",city,   lcity);
  140.   if (eptr(4))  enter_num(15,12, "  phone: ",phone1, lphone1,100,999,15,23);
  141.   if (eptr(5))  enter_num(15,12, "  phone: ",phone2, lphone2,100,999,15,28);
  142.   if (eptr(6))  enter_num(15,12, "  phone: ",phone3, lphone3,1000,9999,15,32);
  143.   if (eptr(7))  enter (17,12,    "comment: ",comment, lcomment,17,22);
  144.   if (eptr(8))  enter_num (19,12,"   date: ",mo,  lmo,  1,12,19,22);
  145.   if (eptr(9))  enter_num (19,12,"   date: ",day, lday, 1,31,19,25);
  146.   if (eptr(10)) enter_num (19,12,"   date: ",year,lyear,0,99,19,28);
  147.   if (eptr(11)) enter_lnum (21,12," check#: ",check,lcheck,lfrom,lto,21,23);
  148.   if (eptr(12))  enter_dollar(23,12," amount:",amt, 23,22);
  149.   if (eptr(13)) {enter(23,50 ,"Press any key ",pak, 1);
  150.          vloc(23,50); vspaces(22);}
  151.  
  152.   eptr_start_with(1);   /* turn off displaying and start entering     */
  153.  
  154. AGAIN
  155. }
  156.  
  157.  
  158.  
  159. jjb_setup() {
  160.     group("Update");
  161.         option("Update customer file");
  162.             funct(update_cust);
  163.         option("Type the");
  164.         option("Description to");
  165.         option("Your options here.",DRAWLINE);
  166.         option("Each group can");
  167.         option("have as many ");
  168.         option("Options as you need.");
  169.  
  170.     group("Other");
  171.         option("These options have no");
  172.         option("functions assigned to them.");
  173.    }
  174.  
  175.  
  176.  
  177.  
  178.